import type { ProjectVO, ProjectForm, ProjectQuery } from './model';

import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 查询研究项目信息列表
 * @param params
 * @returns 研究项目信息列表
 */
export function projectList(params?: ProjectQuery) {
  return requestClient.get<PageResult<ProjectVO>>('/business/project/list', {
    params,
  });
}

/**
 * 查询所有研究项目信息
 * @param params
 * @returns 研究项目信息不分页
 */
export function allProjects(params?: ProjectQuery) {
  return requestClient.get<ProjectVO[]>('/business/project/listProject', {
    params,
  });
}
/**
 * 导出研究项目信息列表
 * @param params
 * @returns 研究项目信息列表
 */
export function projectExport(params?: ProjectQuery) {
  return commonExport('/business/project/export', params ?? {});
}

/**
 * 查询研究项目信息详情
 * @param name id
 * @returns 研究项目信息详情
 */
export function projectInfo(name: ID) {
  return requestClient.get<ProjectVO>(`/business/project/${name}`);
}

/**
 * 新增研究项目信息
 * @param data
 * @returns void
 */
export function projectAdd(data: ProjectForm) {
  return requestClient.postWithMsg<void>('/business/project', data);
}

/**
 * 更新研究项目信息
 * @param data
 * @returns void
 */
export function projectUpdate(data: ProjectForm) {
  return requestClient.putWithMsg<void>('/business/project', data);
}

/**
 * 删除研究项目信息
 * @param name id
 * @returns void
 */
export function projectRemove(name: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/business/project/${name}`);
}
